*----------------------------------------------------------------------	*
* Online Appendix 														*
* The Political Geography of the Gender Gap.						   	*
* Journal of Politics, 2023                                           	*
* Dawn Langan Teele, Johns Hopkins University                         	*
* correspondence: teele.academic@gmail.com                            	*
* Last modificaiton: 01/13/2023                                       	*
* Version of Stata SE 14.2                                            	*
* Operating System Mac OS 12.3                                        	*	 
* ---------------------------------------------------------------------	

********************************************************
*	1. Appendix A: No Figures 
*	2. Appendix B 
*  	3. Appendix C
*	4. Appendix D
********************************************************



*********************************************************
*1: Appendix A: Urbanization, left support, municipality size 
*********************************************************
*See description in text. No figures or tables. 

*********************************************************
*2: Appendix B: Urbanization, left support, municipality size 
*********************************************************
 
 use "Sweden 1911-1944_panel.dta", clear
 
 
 
		collapse (sum) Valid VT VTmen VTwomen Elect Electmen Electwomen SOC LIB CON OTH COM AGR Fris (firstnm) City , by(ID year)
		
*Create national averages
			foreach var of varlist CON LIB SOC COM AGR OTH Fris {
			gen `var'_pct = round((`var'/ Valid )*100, 0.01)
			*hist `var'_pct, name(g`var', replace) 
			
			}

			
	gen lElect=ln(Elect)  /*Electorate size as a proxy for urbanization. Note Stockholm broken into wards so not all are the very largest in the dataset, but close */ 		
	
	la val City city

	
************
*Figure A1
************
	
	cap gen pos=0
	cap gen pipe = "|"

	forvalues n = 5(3)11 {
	local xlab `xlab' `n' "`=string(round(exp(`n'),10),"%9.0fc")'"
	}
	
# delimit ; 
	twoway 		
			
		(lowess SOC_pct lElect, lcolor(cranberry) mlabcolor(cranberry) msym(none) mlabpos(12) lwidth(thick)) 

		(lowess COM_pct lElect, lcolor(red) mlabcolor(red) msym(none) mlabpos(12) lwidth(thick))

		(lowess LIB_pct lElect, lcolor(dkorange) mcolor(dkorange) mlabcolor(dkorange)  msym(none) mlabpos(12) lwidth(thick))

		(lowess CON_pct lElect, lcolor(navy) mcolor(navy) mcolor(navy) mlabcolor(navy) msym(none) mlabpos(12) lwidth(thick)) 

		(lowess AGR_pct lElect if AGR_pct>=0, lcolor(blue) mlabcolor(blue) msym(none) lwidth(thick))

		(lowess OTH_pct lElect, lcolor(gray) mlabcolor(gray) msym(none) mlabpos(12) lwidth(thick))
		
		(lowess Fris_pct lElect, lcolor(orange) mlabcolor(orange) msym(none) mlabpos(12) lwidth(thick))
			
		
		(scatter pos  lElect,   ms(none) mcolor(gs16) mla(pipe) mlabpos(0))	

			, by(year, note("")	style(compact) ) scheme(tufte) 
			ytitle("Partisan Support", size(large) ) 
			xtitle("Electorate Size", size(large) )  xlab(`xlab')  
			
				legend(label(1 "Social Democrats") label(2 "Communists") label(3 "Liberals") label(4 "Conservative ") label(5 "Agrarian") label(6 "Other") label(7 "Proh. Lib") order(1 4 3 2 5) col(3) size(small)) 
			
				
				ylab(0(20)100) ysca(titlegap(*10)) xsca(titlegap(*10))
				; 
		# delimit cr
		
		graph export "./images/appendix/AppFigA1.eps", replace 
		
***************
*Figure A2
**************

forvalues n = 5(3)11 {
	local xlab `xlab' `n' "`=string(round(exp(`n'),10),"%9.0fc")'"
	}

# delimit ; 
			
	twoway 		
			
		(lowess SOC_pct lElect, lcolor(cranberry) mlabcolor(cranberry) msym(none) mlabpos(12) lwidth(thick)) 

		(lowess COM_pct lElect, lcolor(red) mlabcolor(red) msym(none) mlabpos(12) lwidth(thick))

		(lowess LIB_pct lElect, lcolor(dkorange) mcolor(dkorange) mlabcolor(dkorange)  msym(none) mlabpos(12) lwidth(thick))

		(lowess CON_pct lElect, lcolor(navy) mcolor(navy) mcolor(navy) mlabcolor(navy) msym(none) mlabpos(12) lwidth(thick)) 

		(lowess AGR_pct lElect if AGR_pct>=0, lcolor(blue) mlabcolor(blue) msym(none) lwidth(thick))

		(lowess OTH_pct lElect, lcolor(gray) mlabcolor(gray) msym(none) mlabpos(12) lwidth(thick))
		
		(lowess Fris_pct lElect, lcolor(orange) mlabcolor(orange) msym(none) mlabpos(12) lwidth(thick))
			
		
		(scatter pos  lElect,   ms(none) mcolor(gs16) mla(pipe) mlabpos(0))	
 if year==1921
			, by(City, note("") style(compact) ) scheme(tufte) 
			ytitle("Partisan Support", size(large) ) 
			xtitle("Electorate Size", size(large) )   
			xlabel(`xlab')
			legend(label(1 "Social Democrats") label(2 "Communists") label(3 "Liberals") label(4 "Conservative ") label(5 "Agrarian") label(6 "Other") label(7 "Proh. Lib") order(1 4 3 2 5) col(3) size(small)) 
			
				
			ylab(0(20)100) ysca(titlegap(*10)) xsca(titlegap(*10))
				; 
				
		# delimit cr
		
		graph export "./images/appendix/AppFigA2.eps", replace 
		
	

	
*********************************************************
*Appendix C: Male Expansion
*********************************************************
**************************************
*Figure A3: MALE EXPANSION 
**************************************

*Is male expansion correlated with the right support in 1920 election? What about with change in the vote? 

use "Sweden 1911-1944_panel.dta", clear


replace Electmen=Elect if year<=1920

sort ID year
bys ID: gen nmenchange=(Electmen-Electmen[_n-1]) 
la var nmenchange "Numerical Change in Male Electorate"
bys year: sum nmenchange , detail 

sort ID year
bys ID: gen menchange=((Electmen-Electmen[_n-1]) / Electmen[_n-1]) *100 
la var menchange "Percent Change in Male Electorate"
bys year: sum menchange , detail 


bys ID: gen menlast=ln(Electmen[_n-1])
la var menlast "Male electors last election (ln)" 


*gen VTm_percent=(VTm/Electmen)*100
gen VTw_percent=(VTw/Electwomen)*100
la var VTw_percent "Women's Turnout among Eligibles"

gen bigcities=parish_name if Elect>90000 & year==1921
replace bigcities="Malmoe" if ID==1214080
replace bigcities="Stockholm" if province==1


/*
gen bigcities="Malmoe" if ID==1214080
replace bigcities="Stockholm" if province==1
replace bigcities="Gothenberg" if ID==214010
*/



***********************
*Sanity Check: Examining what looks like very high levels of male expansion (not presented in appendix) 
***********************
la val CityTown CityTown

graph hbox nmenchange if red1517==0 & red1820==0 & red21==0, over(year) by(CityTown)

****Outliers ****
	*one very high observation in 1921, and several greater than 5k
		list ID province parish* Elect nmenchange menchange CityTown  if nmenchange>5000 & year==1921
	* I looked up the original data, in Goteburg in 1920, 19,846 men were disqualified from voting, and the number qualified is correct. 	So this is nearly 40% of the men in 1920. 
	* In Malmoe Stad (city) in 1920, 9385 Men were disqualified (and 17514 eligible, so so 35% excluded. 
	* In Norrkoping the parish in 1920 7221 Men were disqualified, the worst! only 51% of men eligible to vote. So these seem correct. 

	*now look at the percent change 
graph hbox menchange if red1517==0 & red1820==0 & red21==0, over(year) by(CityTown)
*graph export "./Sweden_graphs/expansion.eps", replace

			sort menchange 
			list ID province parish* Elect*  nmenchange menchange CityTown  if menchange>100 & year==1921 & menchange!=0 & menchange!=.

			*Solna in stockhokm lans had 3204 ineligible in 1920. 
			*Brannk 1:a and 2: a seem to have had shakeups. 	




*********************
*Figure A3 ~ Density of Male Change 
*********************

*For appendix Density of male change > Definitely a larger change in eligibility in  1921
		twoway (kdensity  menchange if year==1914 & red1114==0, lcolor(green) ) (kdensity  menchange  if year==1917 & red1517==0, lcolor(purple) ) (kdensity  menchange  if year==1920 &red1820==0, lcolor(blue)  )  (kdensity menchange if year==1921 &red21==0, lcolor(magenta) lwidth(thick)) (kdensity menchange if year==1921 & bigcities!="", lcolor(red) lwidth(thick)),  title("Percent Change Male Electorate") scheme(tufte) legend(ring(0) pos(3) label(1 "1911-1914") label(2 "-1917") label(3 "-1920") label(4 "-1921") label(5 "1921, big cities")) xtitle("% Change in Eligibility over Previous Election") ytitle("% of Municipalities")

		graph export "./images/appendix/AppFigA3.eps", replace 

*********************
*Figure A4 ~ Male change by male eligibility in earlier elections. 
*********************
*Correlation of change in male electorate with women's share of eligible voters > places with more voters in 1921 had higher change in male electorate in 1921
version 14
*ssc install tufte
forvalues n = 2(2)12 {
	local xlab `xlab' `n' "`=string(round(exp(`n'),10),"%9.0fc")'"
	}

 *
twoway (scatter menchange menlast,  mlabel(bigcities) mlabpos(12)  mlabcolor(red)) (lfit menchange menlast) if year==1921 & red21==0, ytitle("Change in Male Electorate, %", size(medium)) xtitle("Male Electorate 1920", size(medium)) legend(off) xsca(titlegap(*10)) xlab(`xlab') scheme(tufte) name(g1, replace) 

		graph export "./images/appendix/AppFigA4.eps", replace 

*********************
*Figure A5 ~ Turnout of men and women by the change in male electorate: no turnout response. 
*********************


gen VTm_percent=(VTm/Electmen)*100

twoway (scatter VTm_percent menchange, mlabpos(12) mlabel(bigcities) mcolor(blue)) (scatter VTw_percent menchange , mlabpos(12) mlabel(bigcities) mcolor(pink)) if year==1921 & red21==0, ytitle("Turnout Among Eligible Men and Women", size(medium)) xtitle("Change in Male Electorate % 1921-1922", size(medium)) legend(off) xsca(titlegap(*10)) scheme(tufte) name(g3, replace)

		graph export "./images/appendix/AppFigA5.eps", replace 

*********************
*Figure A6 ~ Change in the Left Vote based on the Change in the Male Electorate
*********************

la var right "Right support, share of valid votes" 
sort ID year
bys ID: gen rightchange=right- right[_n-1]

bys ID: gen leftchange=left- left[_n-1]


twoway (scatter leftchange menchange, mlabpos(12) mlabel(bigcities)) (lowess leftchange menchange) if year==1921 & red21==0, ytitle("Change in Vote for Left", size(medium)) xtitle("Change in Male Electorate % 1921-1922", size(medium)) legend(off) xsca(titlegap(*10)) scheme(tufte) name(g4, replace) yline(0, lcolor(red))
		graph export "./images/appendix/AppFigA6.eps", replace 
 
 
 
*********************
*Figure A7 ~ Turnout was higher in small and large districts; 1920 was a year of low turnout in midsize districts
*********************

use "Sweden 1911-1944_panel.dta", clear

			gen blah=Elect if year==1921
			egen elect1921=max(blah), by(ID)
			replace elect1921=ln(elect1921)
			
			forvalues n = 3(3)12 {
	local xlab `xlab' `n' "`=string(round(exp(`n'),10),"%9.0fc")'"
	}

			
			# delimit ; 
			twoway
			(lowess TE_m elect1921 if year==1921, lcolor(emerald) lwidth(thick)) 
			(lowess TE_m elect1921 if year==1920, lcolor(mint) lwidth(thick)) 
			(lowess TE_m elect1921 if year==1917, lcolor(blue) lwidth(thick))
			(lowess TE_m elect1921 if year==1914, lwidth(thick)) 
			
			, by(City, legend(off) note("") ) ytitle("Men's Turnout", size(large)) xtitle("Electorate Size (1921 value)", size(large) )   text(.6 7 "1921", color(emerald))  text(.52 7 "1920", color(mint)) text(.7 10 "1917", color(blue)) text(.76 10 "1914")  ysca(titlegap(*10)) xsca(titlegap(*10)) xlab(`xlab') 
			;
			# delimit cr 
		graph export "./images/appendix/AppFigA7.eps", replace 

 
 
 
 
***********************************************
*4: Appendix D: Sensitivity Analyses 
*********************************************** 
use simulation2.dta, clear

	
		*Maximum possible men's votes for the left (e.g. assuming no women voted left* 
		gen Bm_UB = (left - 0*(womensharecast)) / (1-womensharecast) if year==1921
		replace Bm_UB=1 if Bm_UB>1 & Bm_UB!=. & year==1921
		
		*with realistic values, about 93 percent of new men could vote for the left with the maximum number of left votes assigned to men if no women voted left. 

		
		*if old men are at their max, and all new men vote left. The proportion of men that vote left: 

forval y=0(.05).3 {
		local x=`y'*100
		gen n=maxleft+`y' if year==1921
		replace n=1 if n>1 & n!=. & year==1921

		gen Bm_`x'=[(TVleft_oldmax) + (n * VT_new)] / VTmen if year==1921
			*Leave men's value empty if it is higher than the max possible 
			replace Bm_`x'=. if Bm_`x'>Bm_UB
		
		
		gen Bw_n`x'= (left - Bm_`x' * (1-womensharecast ))  / womensharecast if year==1921
		
			*substitute with realistic values 
			replace Bw_n`x'=1 if Bw_n`x'>=1 & Bw_n`x'!=.
			replace Bw_n`x'=0 if Bw_n`x'<=0 & Bw_n`x'!=.
			
		
			
			la var Bw_n`x' "Women | New men more left by `x' "
			drop n
		}
	

	
	
	
******************************************************
*Figure A8: Simulation of Women's Leftism under different assumptions of new men voters 
******************************************************	
preserve
	*a little renaming hack so the loop below works
	
	ren Bw_mBm_max1 Bw_n40
	gen Bm_40=1
	
	forvalues n = 4(3)12 {
	local xlab `xlab' `n' "`=string(round(exp(`n'),10),"%9.0fc")'"
	}
			
	
	forval x=0(10)40 { 

# delimit ; 
	 twoway 
		(lowess Bw_n`x' lElect, bwidth(.4) lcolor(magenta)) 
		(lowess maxleft lElect, bwidth(.4) lcolor(mint)) 
		(lowess Bm_`x' lElect, lcolor(emerald) bwidth(.4)) 
		(lowess left lElect, lcolor(black) lpattern(solid)) if year==1921, 
		name(g`x', replace) title("`x' points") 
		legend( label(1 "Women's Estimate") label(2 "Old Men, Most Left Year") label(3 "New Men") label(4 "Actual Results") order(3 4 2 1 ) row(2))  ytitle("Left %") xtitle("Electorate Size") xlab(`xlab')  ; 
	
	#delimit cr
	}
	
	
 
		grc1leg g0 g10 g20 g30 g40
		graph export "./images/appendix/AppFigA8.eps", replace 

restore	

******************************************************
*Figure A9: Distribution of Bw  across urban and rural districts by electorate size
******************************************************	

	*syntax for the rug plot below the figure 3a
	cap gen pos=0  
	cap gen pipe = "|"
	
forvalues n = 4(3)12 {
	local xlab `xlab' `n' "`=string(round(exp(`n'),10),"%9.0fc")'"
	}
			
	
# delimit ; 
			
		twoway 		
			(lowess left lElect , bwidth(.3)lwidth(thick) lpattern(solid) lcolor(gs6))
			(lowess Bw_n0  lElect  , bwidth(.3)lcolor(gs12) lwidth(thick) lpattern(solid) )
			(lowess Bw_n5 lElect  , bwidth(.3)lcolor(gs12) lwidth(thin) lpattern(solid) )
			(lowess Bw_n10 lElect  , bwidth(.3)lcolor(gs12) lwidth(thin) lpattern(solid) )
			(lowess Bw_n15 lElect  , bwidth(.3)lcolor(gs12) lwidth(thin) lpattern(solid) )
			(lowess Bw_n10 lElect  , bwidth(.3)lcolor(gs12) lwidth(thin)lpattern(solid) )
			(lowess Bw_n25 lElect  , bwidth(.3)lcolor(gs12) lwidth(thin) lpattern(solid) )
			(lowess Bw_n30 lElect  , bwidth(.3)lcolor(gs12) lwidth(thin)lpattern(solid) )
			(lowess Bw_mmaxleft lElect  , bwidth(.3)lcolor(magenta) lwidth(thick) lpattern(solid) )
			(lowess Bw_mBm_max1 lElect  , bwidth(.3)lcolor(red) lwidth(thick) lpattern(solid) )
			
			(lowess Bw_m1 lElect , bwidth(.3)lcolor(gs12) lwidth(thick) lpattern(solid) ) 
			(scatter pos lElect ,   ms(none) mcolor(gs16) mla(pipe) mlabpos(0))
							
				if year==1921 & red21==0

				, 
			by(City, note("") ) 
			ytitle("Predicted Votes for the Left (%)", size(large)) 			
			xtitle(Electorate Size, size(large))  legend(off)
			xlab(`xlab')
			ylab( 0(.2)1 )  
			legend(label(1 "1921 Actual Returns") label(9 "Women | Men most left year") label (10 "Women | All new men left")  
			order(1 9 10 ) col(2) size(small)) scheme(tufte) 
				; 
		# delimit cr 

	
		graph export "./images/appendix/AppFigA9.eps", replace 
		
******************************************************
*Figure A10: Distribution of Bw  across urban and rural districts
******************************************************	



# delimit ; 
		twoway 

		(kdensity Bw_n5  , lcolor(gs14) lpattern(solid)) 
		 (kdensity Bw_n10 , lcolor(gs14) lpattern(solid)) 
		 (kdensity Bw_n15 , lcolor(gs14) lpattern(solid)) 
		 (kdensity Bw_n20 , lcolor(gs14) lpattern(solid))
		 (kdensity Bw_n25 , lcolor(gs14) lpattern(solid))
		 (kdensity Bw_n30 , lcolor(gs8) lpattern(solid))
		 
		(kdensity Bw_mmaxleft, lcolor(magenta) lwidth(thick) lpattern(solid))
		(kdensity Bw_mBm_max1, lcolor(red) lwidth(thick) lpattern(solid)) 

		  if year==1921 & red21==0  
		  , 
			by(City, note(""))
		 xtitle("Women's Support for Left") 
		
		 legend(label(7 "If men act like most left year") label(6 "New men 30 points more left") label(8 "All new men left") order(7 6 8) row(1) size(small) )   ;
		 
		 # delimit cr 

	graph export "./images/appendix/AppFigA10.eps", replace 
